package twelfth.字节流与字符流基本操作.字符流.Reader;

import java.io.*;

public class 从文件中读取内容 {
    public static void main(String[] args) throws IOException {
        // 找到操作文件
        String path = "D:" + File.separator + "WorkSpaces" + File.separator +
                "JavaDevelopBase_start_329" + File.separator + "src" + File.separator +
                "twelfth" + File.separator + "WriterDemo.txt";
        File f = new File(path);
        Reader reader = new FileReader(f);
        //读取内容
        char[] chars = new char[1024];
        int len = reader.read(chars);
        reader.close();
        //将数组变为字符串输出
        System.out.println("内容是："+new String(chars,0,len));
    }
}
/*
D:\WorkSpaces\Java\jdk-21\bin\java.exe "-javaagent:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=55542:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\WorkSpaces\JavaDevelopBase_start_329\out\production\JavaDevelopBase_start_329 twelfth.字节流与字符流基本操作.字符流.Reader.从文件中读取内容
内容是：一去二三里
烟村四五家

Process finished with exit code 0

 */